<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>后台用户登录</title>
    <link href="${pageContext.request.contextPath}/login/style_log.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/login/style.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/login/userpanel.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/login/jquery.ui.all.css">

</head>

<body class="login" mycollectionplug="bind">
<div class="login_m">
    <div class="login_padding logintitle" width="250" height="100">系统登录</div>
    <div class="login_boder">

        <div class="login_padding" id="login_model">
            <label>
                <input type="text" id="username" name=username class="txt_input txt_input2" placeholder="账号">
            </label>
            <label>
                <input type="password" id="password" name="password" class="txt_input" placeholder="密码">
            </label>
            <label>
                <input type="text" style="width:100px" ; name="vcode" id="vcode" maxlength="4"
                       class="txt_input txt_input2" placeholder="验证码">
                <img id="vimg" src="${pageContext.request.contextPath}/createCode.jspx" onclick="getCode()"
                     style="cursor: pointer" class="vcode"><a id="kanbuq" href="javascript:;" onclick="getCode();"
                                                              class="vcode-font">点击更换验证码</a>
            </label>
            <p class="forgot"><a id="iforget" href="javascript:void(0);">忘记密码?</a></p>
            <div class="rem_sub">
                <div class="rem_sub_l">
                    <input type="checkbox" name="checkbox" id="save_me">
                    <label for="checkbox">记住密码</label>
                </div>
                <label>
                    <input type="button" class="sub_button" name="button" onclick="userLogin()" id="login_id" value="登录"
                           style="opacity: 0.7;">
                </label>
            </div>
        </div>
        <!--login_padding  Sign up end-->
    </div><!--login_boder end-->
</div><!--login_m end-->
<p align="center">Copyright <a href="http://www.cssmoban.com/" target="_blank" title="博客园">kinglone博客</a> - Collect from
    <a href="http://www.cssmoban.com/" title="kinglone" target="_blank">kinglone</a></p>


<script type="text/javascript" src="${pageContext.request.contextPath}/resources/jquery/jquery.min.js"></script>
<script type="text/javascript"
        src="${pageContext.request.contextPath}/resources/jquery/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/layer/2.4/layer.js"></script>
<script type="text/javascript"
        src="${pageContext.request.contextPath}/resources/plugins/layer/2.4/LayConstant.js"></script>
<script type="text/javascript">

    function userLogin() {
        var username = $("#username").val();
        if ($.trim(username) == null || $.trim(username) == "") {
            layer.msg("请输入用户名!", {icon: 5, time: LayUIConstant.TIP_TIME});
            $("#username").focus();
            return;
        }
        var password = $("#password").val();
        if ($.trim(password) == null || $.trim(password) == "") {
            layer.msg("请输入密码!", {icon: 5, time: LayUIConstant.TIP_TIME});
            $("#password").focus();
            return;
        }
        var vcode = $("#vcode").val();
        if ($.trim(vcode) == null || $.trim(vcode) == "") {
            layer.msg("请输入验证码!", {icon: 5, time: LayUIConstant.TIP_TIME});
            $("#vcode").focus();
            return;
        }
        $.ajax({
            url: '${pageContext.request.contextPath}/user/login.jspx',
            data: {"username": username, "password": password, "vcode": vcode},
            type: 'post',
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    window.location.href = "${pageContext.request.contextPath}/user/main.jspx"
                } else {
                    layer.msg(data.message, {icon: 5, time: LayUIConstant.TIP_TIME});
                    getCode();
                }
            },
            error: function () {
                alert("请求出错!");
            }
        });
    }

    function getCode() {
        $("#vimg").attr("src", "${pageContext.request.contextPath}/createCode.jspx?param=" + Math.random());
    }

    $(window).keydown(function (e) {
        //alert(e.keyCode);
        if (e.keyCode == 13) {
            userLogin();
        }
    });

</script>


</body>
</html>